﻿using System;
using Affinity.Core.Exceptions;

namespace Affinity.Core.Messages
{
    public class ExceptionErrorMessage : ErrorMessage
    {
        public ExceptionErrorMessage(Exception error)
        {
            if (error == null) throw new ArgumentNullException("error");
            Error = error;
        }

        public ExceptionErrorMessage(Exception error, string message, params object[] messageParameters)
        {
            Error = new ExceptionWrapper(
                new ExceptionWrapper.Parameters 
                { 
                    Message = string.Format(message, messageParameters), 
                    WrappedException = error
                });
        }

        public Exception Error { get; private set; }

        public override string Describe()
        {
            return Error.Message;
        }

        public override string DescribeFully()
        {
            return Error.ToString();
        }
    }
}
